﻿Public Class Buscar_Cliente

    Private Sub Buscar_Cliente_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: esta línea de código carga datos en la tabla 'DsClientes.Cliente' Puede moverla o quitarla según sea necesario.
        Me.ClienteTableAdapter.Fill(Me.DsClientes.Cliente)

    End Sub

    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            Me.ClienteDataGridView.Focus()
        End If
        'If Me.TextBox1.Text = "" Then
        '    Dim busca As DataView
        '    busca = Me.DsClientes.Tables(0).DefaultView
        '    Me.ClienteDataGridView.DataSource = busca
        '    Try
        '        busca.RowFilter = "apellido LIKE '*%'"
        '    Catch ex As Exception
        '        MessageBox.Show("Ese Articulo No Existe")
        '    End Try

        'Else
        '    If Me.ComboBox1.Text = "Call ID" Then
        '        Dim busca As DataView
        '        busca = Me.DsClientes.Tables(0).DefaultView
        '        Me.ClienteDataGridView.DataSource = busca
        '        Try
        '            busca.RowFilter = "callId LIKE '" & Me.TextBox1.Text & "%'"
        '        Catch ex As Exception
        '            MessageBox.Show("Ese Articulo No Existe")
        '        End Try
        '    Else
        '        If Me.ComboBox1.Text = "Apellido" Then
        '            Dim busca As DataView
        '            busca = Me.DsClientes.Tables(0).DefaultView
        '            Me.ClienteDataGridView.DataSource = busca
        '            Try
        '                busca.RowFilter = "apellido LIKE '" & Me.TextBox1.Text & "%'"
        '            Catch ex As Exception
        '                MessageBox.Show("Ese Articulo No Existe")
        '            End Try
        '        Else
        '            If Me.ComboBox1.Text = "Nombres" Then
        '                Dim busca As DataView
        '                busca = Me.DsClientes.Tables(0).DefaultView
        '                Me.ClienteDataGridView.DataSource = busca
        '                Try
        '                    busca.RowFilter = "nombre LIKE '" & Me.TextBox1.Text & "%'"
        '                Catch ex As Exception
        '                    MessageBox.Show("Ese Articulo No Existe")
        '                End Try
        '            Else
        '                If Me.ComboBox1.Text = "DNI" Then
        '                    Dim busca As DataView
        '                    busca = Me.DsClientes.Tables(0).DefaultView
        '                    Me.ClienteDataGridView.DataSource = busca
        '                    Try
        '                        busca.RowFilter = "documento LIKE '" & Me.TextBox1.Text & "%'"
        '                    Catch ex As Exception
        '                        MessageBox.Show("Ese Articulo No Existe")
        '                    End Try
        '                Else
        '                    If Me.ComboBox1.Text = "Tel/Cel" Then
        '                        Dim busca As DataView
        '                        busca = Me.DsClientes.Tables(0).DefaultView
        '                        Me.ClienteDataGridView.DataSource = busca
        '                        Try
        '                            busca.RowFilter = "telefono LIKE '" & Me.TextBox1.Text & "%'"
        '                        Catch ex As Exception
        '                            MessageBox.Show("Ese Articulo No Existe")
        '                        End Try
        '                    Else
        '                        If Me.ComboBox1.Text = "Email" Then
        '                            Dim busca As DataView
        '                            busca = Me.DsClientes.Tables(0).DefaultView
        '                            Me.ClienteDataGridView.DataSource = busca
        '                            Try
        '                                busca.RowFilter = "eMail LIKE '" & Me.TextBox1.Text & "%'"
        '                            Catch ex As Exception
        '                                MessageBox.Show("Ese Articulo No Existe")
        '                            End Try
        '                        Else
        '                            If Me.ComboBox1.Text = "Calle" Then
        '                                Dim busca As DataView
        '                                busca = Me.DsClientes.Tables(0).DefaultView
        '                                Me.ClienteDataGridView.DataSource = busca
        '                                Try
        '                                    busca.RowFilter = "calleNombre LIKE '" & Me.TextBox1.Text & "%'"
        '                                Catch ex As Exception
        '                                    MessageBox.Show("Ese Articulo No Existe")
        '                                End Try
        '                            Else
        '                                If Me.ComboBox1.Text = "Altura" Then
        '                                    Dim busca As DataView
        '                                    busca = Me.DsClientes.Tables(0).DefaultView
        '                                    Me.ClienteDataGridView.DataSource = busca
        '                                    Try
        '                                        busca.RowFilter = "calleAltura LIKE '" & Me.TextBox1.Text & "%'"
        '                                    Catch ex As Exception
        '                                        MessageBox.Show("Ese Articulo No Existe")
        '                                    End Try
        '                                Else
        '                                    If Me.ComboBox1.Text = "Fecha Nac" Then
        '                                        Dim busca As DataView
        '                                        busca = Me.DsClientes.Tables(0).DefaultView
        '                                        Me.ClienteDataGridView.DataSource = busca
        '                                        Try
        '                                            busca.RowFilter = "fechaNac LIKE '" & Me.TextBox1.Text & "%'"
        '                                        Catch ex As Exception
        '                                            MessageBox.Show("Ese Articulo No Existe")
        '                                        End Try
        '                                        'end fecha nac
        '                                    End If
        '                                End If
        '                                'end Altura
        '                            End If
        '                            'end Calle
        '                        End If
        '                        'end Email
        '                    End If
        '                    'end dni
        '                End If
        '                'end nombre
        '            End If
        '            'end apellido
        '        End If
        '        'end Call ID
        '    End If


        'End If
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Me.TextBox1.Focus()

    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        If Me.TextBox1.Text = "" Then
            Dim busca As DataView
            busca = Me.DsClientes.Tables(0).DefaultView
            Me.ClienteDataGridView.DataSource = busca
            Try
                busca.RowFilter = "apellido LIKE '*%'"
            Catch ex As Exception
                MessageBox.Show("Ese Articulo No Existe")
            End Try

        Else
            If Me.ComboBox1.Text = "Call ID" Then
                Dim busca As DataView
                busca = Me.DsClientes.Tables(0).DefaultView
                Me.ClienteDataGridView.DataSource = busca
                Try
                    busca.RowFilter = "callId LIKE '" & Me.TextBox1.Text & "%'"
                Catch ex As Exception
                    MessageBox.Show("Ese Articulo No Existe")
                End Try
            Else
                If Me.ComboBox1.Text = "Apellido" Then
                    Dim busca As DataView
                    busca = Me.DsClientes.Tables(0).DefaultView
                    Me.ClienteDataGridView.DataSource = busca
                    Try
                        busca.RowFilter = "apellido LIKE '" & Me.TextBox1.Text & "%'"
                    Catch ex As Exception
                        MessageBox.Show("Ese Articulo No Existe")
                    End Try
                Else
                    If Me.ComboBox1.Text = "Nombres" Then
                        Dim busca As DataView
                        busca = Me.DsClientes.Tables(0).DefaultView
                        Me.ClienteDataGridView.DataSource = busca
                        Try
                            busca.RowFilter = "nombre LIKE '" & Me.TextBox1.Text & "%'"
                        Catch ex As Exception
                            MessageBox.Show("Ese Articulo No Existe")
                        End Try
                    Else
                        If Me.ComboBox1.Text = "DNI" Then
                            Dim busca As DataView
                            busca = Me.DsClientes.Tables(0).DefaultView
                            Me.ClienteDataGridView.DataSource = busca
                            Try
                                busca.RowFilter = "documento LIKE '" & Me.TextBox1.Text & "%'"
                            Catch ex As Exception
                                MessageBox.Show("Ese Articulo No Existe")
                            End Try
                        Else
                            If Me.ComboBox1.Text = "Tel/Cel" Then
                                Dim busca As DataView
                                busca = Me.DsClientes.Tables(0).DefaultView
                                Me.ClienteDataGridView.DataSource = busca
                                Try
                                    busca.RowFilter = "telefono LIKE '" & Me.TextBox1.Text & "%'"
                                Catch ex As Exception
                                    MessageBox.Show("Ese Articulo No Existe")
                                End Try
                            Else
                                If Me.ComboBox1.Text = "Email" Then
                                    Dim busca As DataView
                                    busca = Me.DsClientes.Tables(0).DefaultView
                                    Me.ClienteDataGridView.DataSource = busca
                                    Try
                                        busca.RowFilter = "eMail LIKE '" & Me.TextBox1.Text & "%'"
                                    Catch ex As Exception
                                        MessageBox.Show("Ese Articulo No Existe")
                                    End Try
                                Else
                                    If Me.ComboBox1.Text = "Calle" Then
                                        Dim busca As DataView
                                        busca = Me.DsClientes.Tables(0).DefaultView
                                        Me.ClienteDataGridView.DataSource = busca
                                        Try
                                            busca.RowFilter = "calleNombre LIKE '" & Me.TextBox1.Text & "%'"
                                        Catch ex As Exception
                                            MessageBox.Show("Ese Articulo No Existe")
                                        End Try
                                    Else
                                        If Me.ComboBox1.Text = "Altura" Then
                                            Dim busca As DataView
                                            busca = Me.DsClientes.Tables(0).DefaultView
                                            Me.ClienteDataGridView.DataSource = busca
                                            Try
                                                busca.RowFilter = "calleAltura LIKE '" & Me.TextBox1.Text & "%'"
                                            Catch ex As Exception
                                                MessageBox.Show("Ese Articulo No Existe")
                                            End Try
                                        Else
                                            If Me.ComboBox1.Text = "Fecha Nac" Then
                                                Dim busca As DataView
                                                busca = Me.DsClientes.Tables(0).DefaultView
                                                Me.ClienteDataGridView.DataSource = busca
                                                Try
                                                    busca.RowFilter = "fechaNac LIKE '" & Me.TextBox1.Text & "%'"
                                                Catch ex As Exception
                                                    MessageBox.Show("Ese Articulo No Existe")
                                                End Try
                                                'end fecha nac
                                            End If
                                        End If
                                        'end Altura
                                    End If
                                    'end Calle
                                End If
                                'end Email
                            End If
                            'end dni
                        End If
                        'end nombre
                    End If
                    'end apellido
                End If
                'end Call ID
            End If


        End If
    End Sub
End Class